<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #editorBox {
            width: 500px;
            min-height: 200px;
            border: 1px solid;
        }
    </style>
</head>
<body>
    <div id="editorBox" contenteditable="true">
        hello world!fsdfdsfsdfsfsdf
    </div>
    <button onclick="handleStyle('Bold')">加粗</button>
    <button onclick="handleStyle('Italic')">斜体</button>
    <button onclick="handleStyle('Underline')">下划线</button>
    <button onclick="handleStyle('StrikeThrough')">删除线</button><br/>
    字间距值：<input type="text" id="letterSpacingValue" value="50">px
    <button onclick="setStyle('letterSpacing')">设置字体间距</button><br/>
    <script>
        //设置简单的字体风格
        function handleStyle(type,val) {
            document.execCommand('StyleWithCSS',true,true)
            document.execCommand(type,false,val)
        }
    </script>
</body>
</html>
